﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using ProjBackEnd.Models;
using System.ComponentModel.DataAnnotations;

namespace ProjBackEnd.Areas.BizProj.Models
{
    public class ResultProj : BaseResultInfoPaging
    {
        /// <summary>
        /// 项目扩展信息列表
        /// </summary>
        public List<ProjInfoExt> projinfoextlist { get; set; } = new List<ProjInfoExt>();
    }

    public class ResultPurProj : BaseResultInfoPaging
    {
        /// <summary>
        /// 项目基本信息列表
        /// </summary>
        public List<ProjInfo> projinfolist { get; set; } = new List<ProjInfo>();
    }

    public class ResultProjDtl : BaseResultInfo
    {
        /// <summary>
        /// 项目明细列表
        /// </summary>
        public List<ProjDtlInfoExt> projdtlinfoextlist { get; set; } = new List<ProjDtlInfoExt>();
    }

    /// <summary>
    /// 项目常规信息修改请求
    /// </summary>
    public class ReqProj : BaseUserRequest
    {
        /// <summary>
        /// 项目常规信息
        /// </summary>
        public ProjInfo projinfo { get; set; }
    }

    public class ReqProjProc : BaseUserRequest
    {
        /// <summary>
        /// 项目核心信息
        /// </summary>
        [Required(ErrorMessage ="项目信息是必需的")]
        public ProjInfoCore projcore { get; set; }
    }

    public class ReqProjDtl : BaseUserRequest
    {
        /// <summary>
        /// 项目明细常规信息
        /// </summary>
        [Required(ErrorMessage = "项目明细信息是必需的")]
        public ProjDtlInfo projdtlinfo { get; set; }
    }

    /// <summary>
    /// 项目明细归属转移请求
    /// </summary>
    public class ReqProjDtlTrans : BaseUserRequest
    {
        /// <summary>
        /// 目标合同子项
        /// </summary>
        public int ctsubid_target { get; set; }
        /// <summary>
        /// 源合同子项
        /// </summary>
        public int ctsubid_sour { get; set; }
        /// <summary>
        /// 项目明细id列表
        /// </summary>
        public List<int> dtlidlist { get; set; } = new List<int>();
    }

    /// <summary>
    /// i 项目核心，用于敏感操作
    /// </summary>
    public class ProjInfoCore : BaseOperableEntity
    {
        /// <summary>
        /// 项目流水号
        /// </summary>
        [RequiredConditional("optlb", "UD", ErrorMessage = "项目流水号是必需的")]
        public int projid { get; set; }

        /// <summary>
        /// 所属公司代码
        /// </summary>
        [RequiredConditional("optlb", "I", ErrorMessage = "公司标识是必需的")]
        public string comcd { get; set; }

        /// <summary>
        /// 父级项目流水号
        /// </summary>
        public int pprojid { get; set; }

        /// <summary>
        /// 项目进度
        /// </summary>
        public string pid { get; set; }
    }

    /// <summary>
    /// ii 项目基础信息，用于制单
    /// </summary>
    public class ProjInfo : ProjInfoCore
    {
        /// <summary>
        /// 项目名称
        /// </summary>
        public string projnm { get; set; }
        /// <summary>
        /// 项目描述
        /// </summary>
        public string projdesc { get; set; }
        /// <summary>
        /// 甲方客户id
        /// </summary>
        [RequiredConditional("optlb", "I", ErrorMessage = "甲方客户id是必需的")]
        public int cusid { get; set; }
        /// <summary>
        /// 项目开始时间
        /// </summary>
        [RequiredConditional("optlb", "I", ErrorMessage = "项目开始时间是必需的")]
        public string sdt { get; set; }
        /// <summary>
        /// 项目预计结束时间
        /// </summary>
        public string edt { get; set; }
        /// <summary>
        /// 项目实际结束时间
        /// </summary>
        public string findt { get; set; }
        /// <summary>
        /// 负责人id
        /// </summary>
        public string mgrid { get; set; }
        /// <summary>
        /// 建档人
        /// </summary>
        public string createid { get; set; }
        /// <summary>
        /// 建档时间
        /// </summary>
        public string createdt { get; set; }
        /// <summary>
        /// 合同编号
        /// </summary>
        public string ctno { get; set; }
        /// <summary>
        /// 备注
        /// </summary>
        public string remark { get; set; }
    }

    /// <summary>
    /// iii 项目扩展信息，用于展示
    /// </summary>
    public class ProjInfoExt : ProjInfo
    {
        /// <summary>
        /// 甲方客户名称
        /// </summary>
        public string cusnm { get; set; }
        /// <summary>
        /// 负责人姓名
        /// </summary>
        public string manager { get; set; } = "";
        /// <summary>
        /// 建档人姓名
        /// </summary>
        public string creator { get; set; }
        /// <summary>
        /// 归属项目名称
        /// </summary>
        public string pprojnm { get; set; } = "";
        /// <summary>
        /// 客户默认税率
        /// </summary>
        public decimal deftaxrate { get; set; }
        /// <summary>
        /// 项目状态名称
        /// </summary>
        public string pidnm { get; set; }
    }


    /// <summary>
    /// i 合同清单明细核心，用于敏感操作
    /// </summary>
    public class ProjDtlCore : BaseOperableEntity
    {
        /// <summary>
        /// 合同清单明细流水号
        /// </summary>
        [RequiredConditional("optlb", "UD", ErrorMessage = "项目明细编号是必需的")]
        public int projdtlid { get; set; }
        /// <summary>
        /// 公司代码
        /// </summary>
        public string comcd { get; set; }
        /// <summary>
        /// 合同子项流水号
        /// </summary>
        [RequiredConditional("optlb", "I", ErrorMessage = "合同子项流水号是必需的")]
        public int ctsubid { get; set; }
    }

    /// <summary>
    /// ii 合同清单明细信息，用于制单
    /// </summary>
    public class ProjDtlInfo : ProjDtlCore
    {
        /// <summary>
        /// 明细名称
        /// </summary>
        public string dtlnm { get; set; }
        /// <summary>
        /// 物品类别
        /// </summary>
        public string dtltp { get; set; }
        /// <summary>
        /// 型号
        /// </summary>
        public string model { get; set; }
        /// <summary>
        /// 规格
        /// </summary>
        public string spec { get; set; }
        /// <summary>
        /// 应收数量
        /// </summary>
        public decimal selnum { get; set; }
        /// <summary>
        /// 单位（个、套、件等）
        /// </summary>
        public string unit { get; set; }
        /// <summary>
        /// 应收单价
        /// </summary>
        public decimal amt_recprice { get; set; }
        /// <summary>
        /// 应收总价
        /// </summary>
        public decimal amt_rectotal { get; set; }
        /// <summary>
        /// 应付总价
        /// </summary>
        public decimal amt_paytotal { get; set; }

        /// <summary>
        /// 预估单价
        /// </summary>
        public decimal amt_refprice { get; set; }
        /// <summary>
        /// 预估总价
        /// </summary>
        public decimal amt_reftotal { get; set; }

        /// <summary>
        /// 已审批金额
        /// </summary>
        public decimal amt_approved { get; set; }

        /// <summary>
        /// 数量
        /// </summary>
        public decimal dtlnum { get; set; }
        /// <summary>
        /// 计划销售单价
        /// </summary>
        public decimal amt_selprice { get; set; }
        /// <summary>
        /// 计划销售总价
        /// </summary>
        public decimal amt_seltotal { get; set; }
        /// <summary>
        /// 税率
        /// </summary>
        public decimal taxrate { get; set; }
        /// <summary>
        /// 建档人id
        /// </summary>
        public string createid { get; set; }
        /// <summary>
        /// 建档时间
        /// </summary>
        public string createdt { get; set; }
        /// <summary>
        /// 备注
        /// </summary>
        public string remark { get; set; }
    }

    /// <summary>
    /// iii 合同清单明细扩展信息，用于展示
    /// </summary>
    public class ProjDtlInfoExt : ProjDtlInfo
    {
        /// <summary>
        /// 合同清单明细名称
        /// </summary>
        public string dtltpnm { get; set; }
        /// <summary>
        /// 明细所属项目名称
        /// </summary>
        public string projnm { get; set; }
        /// <summary>
        /// 收款费用笔数
        /// </summary>
        public int feereccount { get; set; }
        /// <summary>
        /// 付款费用笔数
        /// </summary>
        public int feepaycount { get; set; }
        /// <summary>
        /// 项目流水号
        /// </summary>
        public int projid { get; set; }
        /// <summary>
        /// 合同流水号
        /// </summary>
        public int ctid { get; set; }
        /// <summary>
        /// 合同编号
        /// </summary>
        public string ctno { get; set; }
        /// <summary>
        /// 合同名称
        /// </summary>
        public string ctnm { get; set; }
    }

    public class ReqProjApply : BaseUserRequest
    {
        /// <summary>
        /// 申请单信息
        /// </summary>
        [Required(ErrorMessage ="申请单信息是必需的")]
        public ProjApplyInfo projapplyinfo { get; set; }

        private List<ProjDtlCore> lstProjDtlCore = new List<ProjDtlCore>();
        /// <summary>
        /// 申请单明细核心列表
        /// </summary>
        public List<ProjDtlCore> projdtlcorelist { get { return lstProjDtlCore; } set { lstProjDtlCore = value; } }
    }

    public class ReqProjApplySens : BaseUserRequest
    {
        /// <summary>
        /// 申请单核心信息
        /// </summary>
        [Required(ErrorMessage = "申请单信息是必需的")]
        public ProjApplyCore projapplycore { get; set; }
        /// <summary>
        /// 申请单明细核心列表
        /// </summary>
        public List<ProjDtlCore> projdtlcorelist { get; set; } = new List<ProjDtlCore>();
    }

    /// <summary>
    /// 项目申请单结果集
    /// </summary>
    public class ResultProjApply : BaseResultInfo
    {
        /// <summary>
        /// 申请单列表
        /// </summary>
        public List<ProjApplyExt> projapplylist { get; set; }
    }

    /// <summary>
    /// i 申请单核心，用于敏感操作
    /// </summary>
    public class ProjApplyCore : BaseOperableEntity
    {
        /// <summary>
        /// 申请单编号
        /// </summary>
        [RequiredConditional("optlb", "UD", ErrorMessage = "申请单编号是必需的")]
        public int applyid { get; set; }

        /// <summary>
        /// 项目流水号
        /// </summary>
        [RequiredConditional("optlb", "I", ErrorMessage = "项目编号是必需的")]
        public int projid { get; set; }

        /// <summary>
        /// 审批进度：0-建档；1-审批中；2-审批完成；
        /// </summary>
        public string pid { get; set; }

        /// <summary>
        /// 申请单含税金额
        /// </summary>
        public decimal amount { get; set; }

        /// <summary>
        /// 公司代码
        /// </summary>
        public string comcd { get; set; }
    }

    /// <summary>
    /// ii 申请单信息，用于制单
    /// </summary>
    public class ProjApplyInfo : ProjApplyCore
    {
        /// <summary>
        /// 供货商id
        /// </summary>
        public int supid { get; set; }
        /// <summary>
        /// 建档人id
        /// </summary>
        public string createid { get; set; }
        /// <summary>
        /// 建档时间
        /// </summary>
        public string createdt { get; set; }

        /// <summary>
        /// 审批流程id（后期扩展用，暂时为0）
        /// </summary>
        [Required(ErrorMessage ="审批流程是必需的")]
        public int flowid { get; set; }

        /// <summary>
        /// 备注
        /// </summary>
        public string remark { get; set; }
    }

    /// <summary>
    /// iii 申请单扩展信息，用于展示
    /// </summary>
    public class ProjApplyExt : ProjApplyInfo
    {
        /// <summary>
        /// 申请单明细含税金额合计
        /// </summary>
        public decimal dtlamountsum { get; set; }
        /// <summary>
        /// 供货商名称
        /// </summary>
        public string supplier { get; set; }
        /// <summary>
        /// 建档人姓名
        /// </summary>
        public string creator { get; set; }
        /// <summary>
        /// 审核人姓名
        /// </summary>
        public string reviewer { get; set; }
    }


    public class ResultBizContract: BaseResultInfoPaging
    {
        public List<BizContractExtInfo> ctextinfolist { get; set; } = new List<BizContractExtInfo>();
    }

    public class ReqBizContract : BaseUserRequest
    {
        /// <summary>
        /// 业务合同基本信息
        /// </summary>
        public BizContractBaseInfo contbaseinfo { get; set; }
    }

    public class ReqBizContractSens : BaseUserRequest
    {
        /// <summary>
        /// 业务合同核心信息
        /// </summary>
        public BizContractCore contcoreinfo { get; set; }
    }

    /// <summary>
    /// i 业务合同核心，用于敏感操作
    /// </summary>
    public class BizContractCore : BaseOperableEntity
    {
        /// <summary>
        /// 合同流水号
        /// </summary>
        [RequiredConditional("optlb", "UD", ErrorMessage = "合同流水号是必需的")]
        public int ctid { get; set; }
        /// <summary>
        /// 项目流水号
        /// </summary>
        [RequiredConditional("optlb", "I", ErrorMessage = "项目流水号是必需的")]
        public int projid { get; set; }
        /// <summary>
        /// 合同进程
        /// </summary>
        public string pid { get; set; }
        /// <summary>
        /// 客户编号
        /// </summary>
        [RequiredConditional("optlb", "I", ErrorMessage = "客户编号是必需的")]
        public int cusid { get; set; }
        /// <summary>
        /// 公司代码
        /// </summary>
        public string comcd { get; set; }
    }

    /// <summary>
    /// ii 业务合同基本信息，用于常规操作
    /// </summary>
    public class BizContractBaseInfo : BizContractCore
    {
        /// <summary>
        /// 合同编号
        /// </summary>
        public string ctno { get; set; } = "";
        /// <summary>
        /// 合同名称
        /// </summary>
        public string ctnm { get; set; } = "";
        /// <summary>
        /// 合同原始价格
        /// </summary>
        public decimal amt_total { get; set; }
        /// <summary>
        /// 合同最终价格
        /// </summary>
        public decimal amt_final { get; set; }
        /// <summary>
        /// 备注说明
        /// </summary>
        public string remark { get; set; }
        /// <summary>
        /// 签订日期
        /// </summary>
        public string signdt { get; set; }
    }

    /// <summary>
    /// iii 业务合同扩展信息，用于展示
    /// </summary>
    public class BizContractExtInfo : BizContractBaseInfo
    {
        /// <summary>
        /// 客户名称
        /// </summary>
        public string cusnm { get; set; }
        /// <summary>
        /// 客户助记码
        /// </summary>
        public string cusnm_alias { get; set; }
        /// <summary>
        /// 建档人
        /// </summary>
        public string creator { get; set; }
        /// <summary>
        /// 建档日期
        /// </summary>
        public string createdt { get; set; }
    }


    public class ResultBizContractSub : BaseResultInfo
    {
        /// <summary>
        /// 合同分项扩展信息
        /// </summary>
        public List<BizContractSubExtInfo> ctsubextlist { get; set; } = new List<BizContractSubExtInfo>();
    }

    public class ReqBizContractSub : BaseUserRequest
    {
        /// <summary>
        /// 合同分项信息
        /// </summary>
        public BizContractSubCore ctsubcoreinfo { get; set; }
    }

    /// <summary>
    /// i 业务合同分项信息
    /// </summary>
    public class BizContractSubCore : BaseOperableEntity
    {
        /// <summary>
        /// 分项流水号
        /// </summary>
        [RequiredConditional("optlb", "UD", ErrorMessage = "分项流水号是必需的")]
        public int ctsubid { get; set; }
        /// <summary>
        /// 合同流水号
        /// </summary>
        [RequiredConditional("optlb", "I", ErrorMessage = "合同流水号是必需的")]
        public int ctid { get; set; }
        /// <summary>
        /// 分项名称
        /// </summary>
        public string subnm { get; set; } = "";
        /// <summary>
        /// 分项进程
        /// </summary>
        public string pid { get; set; }
    }

    /// <summary>
    /// ii 业务合同分项扩展信息
    /// </summary>
    public class BizContractSubExtInfo: BizContractSubCore
    {
        /// <summary>
        /// 进程名称
        /// </summary>
        public string pidnm { get; set; }
        /// <summary>
        /// 合同编号
        /// </summary>
        public string ctno { get; set; }
        /// <summary>
        /// 合同名称
        /// </summary>
        public string ctnm { get; set; }
        /// <summary>
        /// 归属项目流水号
        /// </summary>
        public int projid { get; set; }
        /// <summary>
        /// 归属项目名称
        /// </summary>
        public string projnm { get; set; }
    }





}